package cn.iocoder.yudao.module.energy.service.device.impl;

import cn.iocoder.yudao.module.energy.dal.mysql.statistics.StatisticsMapper;
import cn.iocoder.yudao.module.energy.service.device.DeviceService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.math.BigDecimal;

/**
 * 能源设备 Service 实现类
 */
@Service
public class DeviceServiceImpl implements DeviceService {

    @Resource
    private StatisticsMapper statisticsMapper;

    @Override
    public Integer getDeviceCount() {
        // 从数据库查询设备总数
        Integer count = statisticsMapper.selectDeviceCount();
        return count != null ? count : 0;
    }

    @Override
    public Double getTotalEnergy() {
        // 从数据库查询设备总能耗
        BigDecimal totalEnergy = statisticsMapper.selectTotalEnergy();
        return totalEnergy != null ? totalEnergy.doubleValue() : 0.0;
    }
} 